﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new GetMapletSessionRequest();
$request->MapletSessionID = $CONF['SESSION_ID'];


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->getMapletSession($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "";

if(isset($response->Commands) && count($response->Commands) > 0)
{
	foreach ($response->Commands as $result)
	{
			$counter++;
			if($result->ControlLayer) {
				$resultString .= "<div><b>".$counter.".&nbsp;ControlLayer </b><br/>";
				$resultString .= "Control: ".$result->ControlLayer->Control."<br/>";
				$resultString .= "LayerIDs: ". implode(", ",$result->ControlLayer->LayerIDs) ."<br/>";
			}
			elseif($result->ControlComponent) {
				$resultString .= "<div><b>".$counter.".&nbsp;ControlComponent</b> <br/>";
				$resultString .= "Component: ".$result->ControlComponent->Component."<br/>";
				$resultString .= "Control: ".$result->ControlComponent->Control."<br/>";
			}
			elseif($result->DeclareMap24Location) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24Location</b><br/>";
				$resultString .= "MapObjectID: ".$result->DeclareMap24Location->MapObjectID."<br/>";
				$resultString .= "Longitude: ".$result->DeclareMap24Location->Coordinate->Longitude."<br/>";
				$resultString .= "Latitude: ".$result->DeclareMap24Location->Coordinate->Latitude."<br/>";
			}
			elseif($result->DeclareMap24Label) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24Label</b><br/>";
				$resultString .= "MapObjectID: ".$result->DeclareMap24Label->MapObjectID."<br/>";
				$resultString .= "Longitude: ".$result->DeclareMap24Label->Coordinate->Longitude."<br/>";
				$resultString .= "Latitude: ".$result->DeclareMap24Label->Coordinate->Latitude."<br/>";
			}
			elseif($result->DeclareMap24HTMLObject) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24HTMLObject</b><br/>";
				$resultString .= "MapObjectID: ".$result->DeclareMap24HTMLObject->MapObjectID."<br/>";
				$resultString .= "Longitude: ".$result->DeclareMap24HTMLObject->Coordinate->Longitude."<br/>";
				$resultString .= "Latitude: ".$result->DeclareMap24HTMLObject->Coordinate->Latitude."<br/>";
			}
			elseif($result->DeclareMap24Polyline) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24Polyline</b><br/>";
				$resultString .= "MapObjectID: ".$result->DeclareMap24Polyline->MapObjectID."<br/>";
				$resultString .= "Longitude: ".$result->DeclareMap24Polyline->Coordinate->Longitude."<br/>";
				$resultString .= "Latitude: ".$result->DeclareMap24Polyline->Coordinate->Latitude."<br/>";
			}
			elseif($result->DeclareMap24Polygon) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24Polygon</b><br/>";
				$resultString .= "MapObjectID: ".$result->DeclareMap24Polygon->MapObjectID."<br/>";
				$resultString .= "Longitude: ".$result->DeclareMap24Polygon->Coordinate->Longitude."<br/>";
				$resultString .= "Latitude: ".$result->DeclareMap24Polygon->Coordinate->Latitude."<br/>";
			}
			elseif($result->DeclareMap24Oval) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24Oval</b><br/>";
				$resultString .= "MapObjectID: ".$result->DeclareMap24Oval->MapObjectID."<br/>";
				$resultString .= "Longitude: ".$result->DeclareMap24Oval->Center->Longitude."<br/>";
				$resultString .= "Latitude: ".$result->DeclareMap24Oval->Center->Latitude."<br/>";
			}
			elseif($result->DeclareMap24ObjectGroup) {
				$resultString .= "<div><b>".$counter.".&nbsp;DeclareMap24ObjectGroup</b><br/>";
				$resultString .= "MapObjectGroup: ".$result->DeclareMap24ObjectGroup->MapObjectGroup."<br/>";
				$resultString .= "MapObjectIDs: ".implode(", ",$result->DeclareMap24ObjectGroup->MapObjectIDs)."<br/>";
			}
			elseif($result->ControlMapObject) {
				$resultString .= "<div><b>".$counter.".&nbsp;ControlMapObject</b><br/>";
				$resultString .= "Control: ".$result->ControlMapObject->Control."<br/>";
				$resultString .= "MapObjectIDs: ".implode("<br/>",$result->ControlMapObject->MapObjectIDs)."<br/>";
			}
			elseif($result->SetMapView) {
				$resultString .= "<div><b>".$counter.".&nbsp;SetMapView</b><br/>";
				$resultString .= "<u>ClippingWidth</u> <br/>";
				$resultString .= "MinimumWidth:" . $result->SetMapView->ClippingWidth->MinimumWidth."<br/>";
				$resultString .= "ViewPercentage:" . $result->SetMapView->ClippingWidth->ViewPercentage."<br/>";
				$resultString .= "Pitch:" . $result->SetMapView->ClippingWidth->Pitch."<br/>";
				$resultString .= "Rotation:" . $result->SetMapView->ClippingWidth->Rotation."<br/>";
			}

			$resultString .= "<br/><br/></div>";
	}
}
else
{
	$resultString = "No Commands in the session";
}
?>